
function showTab(node) {
	var tabs = mini.get("mainTabs");
	var id = "tab$" + node.id;
	var tab = tabs.getTab(id);
	if (!tab) {
        tab = {};
        tab._nodeid = node.id;
        tab.name = id;
        tab.title = node.text;
        if(tab.title == "商户管理"){
        	alert("待开发功能");
        	return;
        }
        tab.showCloseButton = true;

        //这里拼接了url，实际项目，应该从后台直接获得完整的url地址
        tab.url = mini_JSPath + node.url;
		//alert(node.url);
        tabs.addTab(tab);
    }
    tabs.activeTab(tab);    
}	
	
function onNodeSelect(e) {
	//window.location.reload();
   var node = e.node;
   var isLeaf = e.isLeaf;

    if (isLeaf) {
        showTab(node);
    }
}	
	

function onLoadError(e){
	//sys.manage.struts.action.AdminUserAction
	var pos_value = e.errorMsg.indexOf("sys.manage.struts.action.AdminUserAction");
	if(pos_value > 0){
		mini.showMessageBox(
				{
        			title: "提示",    
        		    message: "您还没登录，请先登录",
        		    buttons: ["ok"],    
        		    iconCls: "mini-messagebox-error",
        		    callback: function(action){
        		    	window.location.href='http://localhost:8080/sys_manage';
        		    }
        		}
       );
	}else{
		mini.showMessageBox(
				{
        			title: "提示",    
        		    message: "不能获取权限信息，请联系管理员或重试！",
        		    buttons: ["ok"],    
        		    iconCls: "mini-messagebox-warning"
        		}			
       );
	}
	
}
	
function onClick(e) {
    var text = this.getText();
    alert(text);
}	
	
function onQuickClick(e) {
    tree.expandPath("datagrid");
    tree.selectNode("datagrid");
}	
	
function onTabsActiveChanged(e) {
    var tabs = e.sender;
    var tab = tabs.getActiveTab();
    if (tab && tab._nodeid) {
		
        var node = tree.getNode(tab._nodeid);
        if (node && !tree.isSelectedNode(node)) {
            tree.selectNode(node);
        }
    }
}	

function pageFirst(){
	window.location.href=getRootPath()+"/pages/index.html";
}
	
function close(){
	mini.showMessageBox(
			{
    			title: "提示",    
    		    message: "是否关闭？",
    		    buttons: ["ok","cancel"],    
    		    iconCls: "mini-messagebox-warning",
    		    callback: function(action){
    		    	if(action=="ok"){
    		    		window.location.href=getRootPath()+"/pages/access/admin_login.html";
    		    	}
    		    }
    		}
   );
}